Get premium membership and access questions with answers, video lessons as well as revision papers.

What is wrong with following program? // This program has an error. #include using namespace std; void triple(double &num); int main() { double d = 7.0; tripe(&d); cout << d; return 0; } //...

      

What is wrong with following program?
// This program has an error.
#include
using namespace std;
void triple(double &num);
int main()
{
double d = 7.0;
tripe(&d);
cout << d;
return 0;
}
// Triple num's value.
void triple(double &num)
{
num = 3 * num;
}

  

Answers


Davis
When triple() is called, the address of d is licitly obtained with the & operator.This is neither necessary nor legal.When a reference parameter is used, the argument is not preceded by the &
Githiari answered the question on May 31, 2018 at 17:08


Next: Write a C++ function called neg() that reverses the sign of its integer parameter.Write the function two ways-first by using a pointer parameter and then...
Previous: a)Create a class that contains a person's name and telephone number. Using new, dynamically allocate an object of this class and put your name and...

View More Computer Studies Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions